﻿namespace DimensionsHelper.Client.WinUi.Services;

public class MessageService : IMessageService
{
    public async Task ShowAsync(string message, string? title)
    {
        ContentDialog? dialog = new()
        {
            XamlRoot = App.MainWindow.Content.XamlRoot,
            Title = title ?? "注意",
            CloseButtonText = "关闭",
            Content = new TextBlock { Text = message }
        };

        await dialog.ShowAsync();
    }


    public async Task ShowAsync(string message, string? title, string button, Action clickAction)
    {
        ContentDialog? dialog = new()
        {
            XamlRoot = App.MainWindow.Content.XamlRoot,
            Title = title ?? "注意",
            CloseButtonText = "关闭",
            PrimaryButtonText = button,
            PrimaryButtonCommand = new RelayCommand(clickAction),
            Content = new TextBlock { Text = message }
        };

        await dialog.ShowAsync();
    }
}